<template>
  <div>
    <a-row>
      <!-- <a-card>
        <a-col :span="2">
          <a-input placeholder="角色名" v-model="roleName" />
        </a-col>
        <a-col :span="2" style="margin-left: 5px">
          <a-input placeholder="角色标识" v-model="roleCode" />
        </a-col>
      </a-card> -->
      <a-col :span="24">
        <a-card>
          <div style="margin-bottom: 8px">
            <a-button type="primary" icon="plus"> 添加 </a-button>
          </div>
          <!-- 表格 -->
          <a-table
            :columns="columns"
            :row-key="(record) => record.roleId"
            :data-source="treeData"
            :pagination="pagination"
            :loading="loading"
            @change="handleTableChange"
          >
            <template slot="action" slot-scope="text, record">
              <a-button-group>
                <a-button type="link" size="small" @click="onEdit(record)"
                  >编辑</a-button
                >
                <a-button type="link" size="small" @click="onAuth(record)"
                  >授权</a-button
                >
                <a-popconfirm
                  title="确定删除?"
                  @confirm="() => onDelete(record)"
                >
                  <a-button type="link" size="small">删除</a-button>
                </a-popconfirm>
              </a-button-group>
            </template>
          </a-table>
        </a-card>
      </a-col>
    </a-row>
    <!-- 添加 编辑弹层 -->
    <!-- 授权弹层 -->
  </div>
</template>

<script>
import { treeList } from "@/services/menu/menu";
const columns = [
  {
    title: "",
    dataIndex: "roleName",
    key: "roleName",
    align: "center",
  },
  {
    title: "权限名称",
    dataIndex: "menuName",
    key: "roleCode",
    align: "center",
  },
  {
    title: "描述",
    dataIndex: "details",
    key: "details",
    align: "center",
  },
  {
    title: "是否启用",
    dataIndex: "enable",
    key: "enable",
    align: "center",
    scopedSlots: {
      customRender: "enable",
    },
  },
  {
    title: "排序",
    dataIndex: "sort",
    key: "sort",
    align: "center",
  },
  {
    title: "创建时间",
    dataIndex: "createTime",
    key: "createTime",
    align: "center",
  },
  {
    title: "更新时间",
    dataIndex: "updateTime",
    key: "updateTime",
    align: "center",
  },
  {
    title: "操作",
    dataIndex: "operate",
    align: "center",
    scopedSlots: {
      customRender: "action",
    },
  },
];
export default {
  name: "Menu",
  data() {
    return {
      value: 1,
      columns,
      pagination: false,
      roleId: "",
      treeData: [],
    };
  },
  computed: {},
  methods: {
    getTreeList() {
      treeList().then((result) => {
        let res = result.data;
        this.treeData = res.data;
      });
    },
  },
  mounted() {
    this.getTreeList();
  },
};
</script>

<style>
</style>
